package com.jic.market.mapper;

import com.jic.market.entity.PromotionLimitRuleEntity;
import com.jic.market.model.LimitQueryUniqueCondition;
import com.jic.market.orm.BaseMapper;
import com.jic.market.entity.PatchGrouponStockLmtEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PatchGrouponStockLmtEntityMapper extends BaseMapper<PatchGrouponStockLmtEntity> {

    PatchGrouponStockLmtEntity getEntityByPromotionIdAndMpId(@Param("promotionId") Long promotionId, @Param("mpId") Long mpId);

    /**
     * @param condition
     * @return
     */
    PatchGrouponStockLmtEntity getEntityLimitQueryUniqueCondition(LimitQueryUniqueCondition condition);


    Integer updateLimit(PatchGrouponStockLmtEntity param);

    /**
     * 更新 limit 通过 id
     * @param param
     * @return
     */
    Integer updateLimitById(PatchGrouponStockLmtEntity param);


    /**
     * 根据 促销id 和 商品id 删除
     * @param promotionId
     * @param productId
     * @return
     */
    Integer deleteEntityByPromotionIdAndMpId(
            @Param("promotionId") Long promotionId, @Param("productId") Long productId);

    /**
     * 根据 促销商品id删除
     * @param patchGrouponMpId
     * @return
     */
    Integer deleteByPatchGrouponMpId(@Param("patchGrouponMpId") Long patchGrouponMpId);

    /**
     * 根据 促销id 和 店铺ids  删除 stock 限制项
     * @param promotionId
     * @param storeIds
     * @return
     */
    Integer deleteEntityListByPromotionIdAndStoreIdsBatch(
            @Param("promotionId") Long promotionId, @Param("storeIds") List<Long> storeIds);

    Integer insertBatch( @Param("items")List<PatchGrouponStockLmtEntity> list);
}